package com.hdy.net.order;

import com.hdy.common.statistics.HdyStatistics;

import rx.Subscriber;

public class OrderSubscriber<T> extends Subscriber<T> {

    NetCallback mNetCallback;

    public OrderSubscriber(NetCallback<T> callback) {
        mNetCallback = callback;
    }

    @Override
    public void onStart() {
        super.onStart();
        if (mNetCallback != null) {
            mNetCallback.onStart();
        }
    }

    @Override
    public void onCompleted() {
        if (mNetCallback != null) {
            mNetCallback.onCompleted();
        }
    }

    @Override
    public void onError(Throwable e) {
        HdyStatistics.getInstance().onError(e);
        if (mNetCallback != null) {
            mNetCallback.onError(e);
        }
    }

    @Override
    public void onNext(T t) {
        if (mNetCallback != null) {
            mNetCallback.onNext(t);
        }
    }
}
